﻿namespace Loki.UI
{
    public static class UIContext
    {
        private static IThreadingContext threading;

        private static ITemplatingEngine templates;

        private static IWindowManager windows;

        public static void Configure(IPlatform platform)
        {
            if (platform != null)
            {
                threading = platform.Threading;
                templates = platform.Templates;
                windows = platform.Windows;
            }
            else
            {
                threading = new DefaultThreadingContext();
            }
        }

        public static void GetFromCurrentThread()
        {
            Configure(null);
        }

        /// <summary>
        /// Gets the templating engine.
        /// </summary>
        /// <value>
        /// The templating engine.
        /// </value>
        public static ITemplatingEngine Templates
        {
            get { return templates; }
        }

        /// <summary>
        /// Gets the threading wrapper.
        /// </summary>
        /// <value>
        /// The threading wrapper.
        /// </value>
        public static IThreadingContext Threading
        {
            get { return threading; }
        }

        /// <summary>
        /// Gets the windows manager.
        /// </summary>
        /// <value>
        /// The windows manager.
        /// </value>
        public static IWindowManager Windows
        {
            get { return windows; }
        }
    }
}